package com.zc58s.rabbitmqdemo3.mq;

import com.rabbitmq.client.Channel;
import com.zc58s.rabbitmqdemo3.config.RabbitMQConfig;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/**
 * @author : fujc-dev@qq.com
 * @created : 2022/8/21 10:20
 */
@Component
public class ReceiveHandler {

    @RabbitListener(queues = {RabbitMQConfig.QUEUE_INFORM_EMAIL})
    public void receiveEmail(String body, Message message, Channel channel) {
        System.out.println(body);
        System.out.println("接收到消息：" + new String(message.getBody(), StandardCharsets.UTF_8));
    }
}
